package com.shareroad.dubboweb.frame.handler.impl;

import com.alibaba.dubbo.common.utils.StringUtils;
import com.alibaba.dubbo.config.ReferenceConfig;
import com.alibaba.fastjson.JSONObject;
import com.shareroad.dubboweb.frame.handler.ApiHandler;

@SuppressWarnings({"rawtypes","unchecked"})
public class ApiHandlerImpl implements ApiHandler {
	
	private ReferenceConfig referenceConfig; 

	public ReferenceConfig getReferenceConfig() {
		return referenceConfig;
	}

	public void setReferenceConfig(ReferenceConfig referenceConfig) {
		this.referenceConfig = referenceConfig;
	}

	@Override
	public JSONObject invokeDubboService(String interfaceName, String version,String method,
			JSONObject params) throws Exception{
		Class inter = Class.forName(interfaceName);
		referenceConfig.setInterface(inter);
		if(!StringUtils.isBlank(version)){
			referenceConfig.setVersion(version);
		}
		// 和本地bean一样使用xxxService
		Object dubboService = referenceConfig.get(); // 注意：此代理对象内部封装了所有通讯细节，对象较重，请缓存复用
		//反射执行
		
		
		return null;
	}

}
